package com.zuipin.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zuipin.entity.product.PropertiesInfo;
import com.zuipin.entity.product.PropertiesVal;
import com.zuipin.framework.annotation.Inject;
import com.zuipin.framework.annotation.Json;
import com.zuipin.framework.annotation.Jsons;
import com.zuipin.framework.annotation.Valid;
import com.zuipin.framework.annotation.Valids;
import com.zuipin.framework.emuns.ErrorCode;
import com.zuipin.framework.exception.CustomException;
import com.zuipin.framework.result.PageResult;
import com.zuipin.framework.result.Result;
import com.zuipin.service.ICategoryInfoService;
import com.zuipin.service.ICategroyPropertiesService;
import com.zuipin.service.IPropertiesInfoService;
import com.zuipin.util.DateUtils;
import com.zuipin.util.Pagination;
import com.zuipin.util.StringUtil;
import com.zuipin.vo.BackPropValViewVo;
import com.zuipin.vo.BackPropViewVo;
import com.zuipin.vo.BackSetCatePropValViewVo;
import com.zuipin.vo.BackSetCatePropViewVo;
import com.zuipin.vo.ModityBaseProp;
import com.zuipin.vo.ModityPropertiesValVo;
import com.zuipin.vo.PropDetailVo;
import com.zuipin.vo.PropInfoSearchVo;
import com.zuipin.vo.PropViewSearchVo;
import com.zuipin.vo.PropertiesInfoVo;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import net.sf.json.JSONObject;
import springfox.documentation.annotations.ApiIgnore;

/**
 * 
 *
 * @ClassName PropertiesInfoController
 * @author wangcongyi
 * @date 2017年4月20日 下午3:22:52
 */
@Controller
@RequestMapping(value = "/propInfo")
@Api(value = "属性", description = "属性信息-wangcongyi")
public class PropertiesInfoController {
	
	@Resource
	private ICategoryInfoService		categoryInfoService;
	@Resource
	private IPropertiesInfoService		propertiesInfoService;
	@Resource
	private ICategroyPropertiesService	catgroyPropertiesService;
	
	@Jsons({ @Json(type = PropertiesInfoVo.class), @Json(type = PropertiesVal.class, include = "id,catPropId,propVal") })
	@RequestMapping(value = "/queryPropVal", method = RequestMethod.GET)
	@ApiOperation(value = "518-查询属性值列表-wangcongyi", notes = "查询属性值列表")
	@Valids({ @Valid(name = "catId", required = true, maxValue = 99999), @Valid(name = "sysId", required = true, maxValue = 20),
			@Valid(name = "device", required = true, regex = "WAP|PC"), @Valid(name = "position", required = true, maxValue = 20),
			@Valid(name = "isDisplay", minValue = 0, maxValue = 1) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "catId", value = "品类ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "sysId", value = "系统ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "device", value = "终端,PC|WAP", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "position", value = "位置,0 详情 |1筛选", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "isDisplay", value = "是否显示空属性值的属性", defaultValue = "0", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "state", value = "属性状态'ENABLE','DISABLE','NOT_ACTIVE'", required = false, dataType = "string", paramType = "query") })
	public Result<?> queryPropVal(@RequestParam(value = "catId", required = true) Long catId, @RequestParam(value = "sysId", required = true) Long sysId,
			@RequestParam(value = "device", required = true) String device, @RequestParam(value = "position", required = true) Long position,
			@RequestParam(value = "state", required = false) Long state, @RequestParam(value = "isDisplay", required = false, defaultValue = "0") Long isDisplay) {
		Result<List<PropertiesInfoVo>> result = new Result<>();
		JSONObject params = new JSONObject();
		params.put("catId", catId);
		params.put("sysId", sysId);
		params.put("device", device);
		params.put("position", position);
		params.put("state", state);
		// 判断isDisplay是否有值否则为默认值
		if (null == isDisplay) {
			isDisplay = 0L;
		}
		params.put("isDisplay", isDisplay);
		List<PropertiesInfoVo> vos = propertiesInfoService.selectPropInfo(params);
		result.setData(vos);
		result.setErrorCode(ErrorCode.SUCCESS);
		return result;
	}
	
	/**
	 * 后台 筛选条件（基础属性  分类属性）获取 属性信息
	 * @author zhuangjiajian
	 * @return
	 */
	@RequestMapping(value = "/findPropInfo", method = RequestMethod.POST)
	@ResponseBody
	@ApiOperation(value = "5期-zhuangjiajian-后台 筛选条件（基础属性  分类属性）获取 属性信息", notes = "1.只传catId时查询通用的分类属性 2.传sysId catId时查询平台下的分类属性 3.不传catId时只查基础属性信息")
	@Valids({ @Valid(name = "propSearchVo.propType"), //
			@Valid(name = "propSearchVo.state", regex = "ENABLE|DISABLE"), //
			@Valid(name = "propSearchVo.sysId", required = false, maxValue = 20, minValue = 1), //
			@Valid(name = "page.pageNumber", required = true), //
			@Valid(name = "page.pageSize", required = true) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "propSearchVo.catId", value = "品类ID", required = false, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "propSearchVo.sysId", value = "系统ID", required = false, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "propSearchVo.propNo", value = "属性编号", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "propSearchVo.propCodeOrNameSearch", value = "属性编码或者名称", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "propSearchVo.propName", value = "属性名称", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "propSearchVo.propType", value = "属性类型 1多选项 2文本项", required = false, dataType = "integer", paramType = "query"),
			@ApiImplicitParam(name = "propSearchVo.state", value = "属性状态（禁用 DISABLE,启用 ENABLE）", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "page.pageNumber", value = "页码", required = true, dataType = "integer", paramType = "query"),
			@ApiImplicitParam(name = "page.pageSize", value = "单页记录数", required = true, dataType = "integer", paramType = "query") })
	public Result<List<PropertiesInfo>> findPropInfo(@Inject @ApiIgnore PropInfoSearchVo propSearchVo, @Inject @ApiIgnore Pagination page) {
		return propertiesInfoService.findPropInfo(propSearchVo, page);
		
	}
	
	/**
	 * 查看（基础属性,通用分类属性,平台分类属性）详情
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findPropInfoDetail", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-后台查看（基础属性,通用分类属性,平台分类属性）详情", notes = "查看分类属性时 传catId  查看平台分类属性时再传个sysId")
	@Valids({})
	@ApiImplicitParams({ @ApiImplicitParam(name = "propId", value = "属性ID", required = true, dataType = "long", paramType = "query") })
	public Result<PropDetailVo> findPropInfoDetail(@RequestParam(value = "propId") Long propId, @RequestParam(value = "sysId", required = false) Long sysId,
			@RequestParam(value = "catId", required = false) Long catId) {
		// 通过属性ID查询 详情信息 如果属性类型为文本则不显示属性值信息 如为多选则显示属性值信息
		
		Result<PropDetailVo> result = new Result<PropDetailVo>();
		PropDetailVo vo = propertiesInfoService.findPropInfoDetail(propId, catId, sysId);
		if (vo == null) {
			result.setErrorCode(ErrorCode.NOT_FIND);
			result.setData(null);
			result.setMessage("未找到该属性信息");
			return result;
		}
		result.setData(vo);
		result.setErrorCode(ErrorCode.SUCCESS);
		return result;
	}
	
	/**
	 * 判断属性是否有被 分类属性引用（通用 平台）  是否可编辑
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/isCanEditProp", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-判断属性是否有被 分类属性引用（通用 平台）", notes = "判断属性是否有被 分类属性引用（通用 平台）")
	@Valids({})
	@ApiImplicitParams({ @ApiImplicitParam(name = "propId", value = "属性ID", required = true, dataType = "long", paramType = "query") })
	public Result<Boolean> isCanEditProp(@RequestParam(value = "propId") Long propId) {
		// 判断属性是否有被 分类属性引用（通用 平台）
		// 被禁用属性 或者 被其他分类属性引用的属性 不可编辑
		return propertiesInfoService.isCanEditProp(propId);
	}
	
	/**
	 * 后台编辑或者添加属性信息  修改属性值 名称 备注
	 * @author zhuangjiajian
	 * @return
	 * @throws CustomException 
	 */
	@ResponseBody
	@RequestMapping(value = "/updateOrAddPropAndVal", method = RequestMethod.POST)
	@ApiOperation(value = "5期-zhuangjiajian-后台编辑属性信息 修改属性值 名称 备注", notes = "后台编辑或者增加属性信息 修改属性值 名称 备注（有传属性id的时候就是编辑没有则为添加）")
	@Valids({ @Valid(name = "modityBaseProp.propType", minValue = 1, maxValue = 2, required = true), //
			@Valid(name = "modityBaseProp.propNo", required = false, maxLength = 20), //
			@Valid(name = "modityBaseProp.propName", required = true, maxLength = 20), //
			@Valid(name = "modityBaseProp.remark", required = false, maxLength = 500), //
			@Valid(name = "modityBaseProp.updateId", required = true), //
			@Valid(name = "modityBaseProp.propValList.propVal", required = false, maxLength = 100), //
			@Valid(name = "modityBaseProp.propId", required = false), //
	})
	public Result<Boolean> updateOrAddPropAndVal(@RequestBody ModityBaseProp modityBaseProp) throws CustomException {
		// 添加属性 属性值 事务问题 有传propId时则为添加操作 反之则为更新操作
		if (modityBaseProp.getPropId() != null) {
			// 更新操作
			return propertiesInfoService.updatePropAndVal(modityBaseProp);
		}
		// 增加操作
		/*StringBuilder separator = new StringBuilder("");
		StringBuilder sb = new StringBuilder();*/
		
		String propVals = "";
		if (modityBaseProp.getPropValList() != null && modityBaseProp.getPropValList().size() > 0) {
			
			/*for (ModityPropertiesValVo pro : modityBaseProp.getPropValList()) {
				if (!StringUtil.isBlank(pro.getPropVal())) {
					sb.append(separator).append(pro.getPropVal());
					separator = new StringBuilder(",");*/
			
			for (int i = 0; i < modityBaseProp.getPropValList().size(); i++) {
				ModityPropertiesValVo pro = modityBaseProp.getPropValList().get(i);
				if (pro != null && !StringUtil.isBlank(pro.getPropVal())) {
					propVals += pro.getPropVal();
					if (i != (modityBaseProp.getPropValList().size() - 1)) {
						propVals += ",";
					}
				}
			}
		}
		return propertiesInfoService.addPropAndVal(propVals, modityBaseProp.getUpdateId(), modityBaseProp.getPropName(), modityBaseProp.getPropNo(), modityBaseProp.getPropType(),
				modityBaseProp.getRemark());
		
	}
	
	@ResponseBody
	@RequestMapping(value = "/modifyState", method = RequestMethod.POST)
	@ApiOperation(value = "5期----------属性信息启用禁用(后台)", notes = "属性信息启用禁用(后台)")
	@Valids({ @Valid(name = "prop.id", required = true), //
			@Valid(name = "prop.state", required = true, regex = "ENABLE|DISABLE"), })
	@ApiImplicitParams({ //
			@ApiImplicitParam(name = "prop.id", value = "属性ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "prop.state", value = "状态（禁用 DISABLE,启用 ENABLE）", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "prop.updateId", value = "更新者ID", required = true, dataType = "long", paramType = "query") })
	public Result<?> modifyState(@Inject @ApiIgnore PropertiesInfo prop) {
		/*
			禁用属性的影响：该属性如果被商品分类引用，则自动置灰禁用（在分类属性管理中，商品分类对应的属性置灰，不可编辑，可删除该属性；
			如果在分类属性管理中未删除禁用属性，在SKU管理-商品详情中该属性置灰，不可编辑，不可删除；如果在分类属性管理中删除禁用属性，则对应的SKU管理-商品详情中该属性字段和属性值都消失）；
			禁用属性不可再被商品分类引用
		 */
		Result<Integer> result = new Result<>();
		// 判断是否已经启用或禁用状态
		// PropertiesInfo propertiesInfo = propertiesInfoService.isExists(prop);
		
		PropertiesInfo propertiesInfo = propertiesInfoService.selectByPrimaryKey(prop.getId());
		StringBuilder statusStr = new StringBuilder();
		
		if (null != propertiesInfo) {
			// 判断用户传值
			if (PropertiesInfo.ENABLE.equals(prop.getState())) {
				statusStr.append("启用");
			} else {
				statusStr.append("禁用");
			}
			
			if (PropertiesInfo.ENABLE.equals(prop.getState()) && !PropertiesInfo.DISABLE.equals(propertiesInfo.getState())) {
				result.setErrorCode(ErrorCode.MODITY_STATUS_FAIL);
				result.setMessage("只有禁用才能启用");
				return result;
			}
			
			if (PropertiesInfo.DISABLE.equals(prop.getState()) && !PropertiesInfo.ENABLE.equals(propertiesInfo.getState())) {
				result.setErrorCode(ErrorCode.MODITY_STATUS_FAIL);
				result.setMessage("只有启用才能禁用");
				return result;
			}
			
			// 更新状态
			propertiesInfo.setState(prop.getState());
			propertiesInfo.setUpdateId(prop.getUpdateId());
			propertiesInfo.setUpdateTime(DateUtils.getCurrentDateTime());
			propertiesInfoService.updateByPrimaryKeySelective(propertiesInfo);
			// boolean falg = propertiesInfoService.modifyState(prop);
			result.setErrorCode(ErrorCode.SUCCESS);
			result.setMessage("属性[" + propertiesInfo.getPropNo() + "]" + statusStr + "成功！");
		} else {
			result.setErrorCode(ErrorCode.NOT_FIND);
			result.setMessage("属性不存在");
		}
		return result;
	}
	
	/**
	 * 更新分类属性信息(通用)
	 * @author zhuangjiajian
	 * @return
	 * @throws CustomException 
	 */
	@ResponseBody
	@RequestMapping(value = "/updateCateProps", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-更新分类属性信息", notes = "更新分类属性信息(通用)")
	@Valids({ @Valid(name = "propIds", required = false) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "propIds", value = "属性ID集", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "catId", value = "分类属性ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "updateId", value = "更新者ID", required = true, dataType = "long", paramType = "query") })
	public Result updateCateProps(@RequestParam(value = "propIds", required = false) String propIds, @RequestParam(value = "catId") Long catId,
			@RequestParam(value = "updateId") Long updateId) throws CustomException {
		
		return propertiesInfoService.updateCateProps(propIds, catId, updateId);
	}
	
	/**
	 * 删除分类下的属性信息(通用)
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/delCateProps", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-删除分类下的属性信息(通用)", notes = "删除分类下的属性信息(通用)")
	@Valids({})
	@ApiImplicitParams({ @ApiImplicitParam(name = "propId", value = "属性ID集", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "catId", value = "分类属性ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "updateId", value = "更新者ID", required = true, dataType = "long", paramType = "query") })
	public Result delCateProps(@RequestParam(value = "propId") Long propId, @RequestParam(value = "catId") Long catId, @RequestParam(value = "updateId") Long updateId) {
		
		return propertiesInfoService.delCateProps(propId, catId);
	}
	
	/**
	 * 更新分类属性值信息(通用)
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/updateCatePropVals", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-更新分类属性值信息(通用)", notes = " 更新分类属性值信息(通用)")
	@Valids({ @Valid(name = "propValIds", required = false) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "propId", value = "属性ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "propValIds", value = "属性值ID集", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "catId", value = "分类属性ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "updateId", value = "更新者ID", required = true, dataType = "long", paramType = "query") })
	public Result<Boolean> updateCatePropVals(@RequestParam(value = "propId") Long propId, @RequestParam(value = "propValIds", required = false) String propValIds,
			@RequestParam(value = "catId") Long catId, @RequestParam(value = "updateId") Long updateId) {
		
		return propertiesInfoService.updateCatePropVals(propId, propValIds, catId, updateId);
	}
	
	/**
	 * 平台分类属性的展示
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/showCatePropView", method = RequestMethod.POST)
	@ApiOperation(value = "5期-zhuangjiajian-平台分类属性的展示", notes = "平台分类属性的展示")
	@Valids({ @Valid(name = "searchVo.sysId", required = true, minValue = 1), @Valid(name = "page.pageNumber", required = true), //
			@Valid(name = "page.pageSize", required = true) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "page.pageNumber", value = "页码", required = true, dataType = "integer", paramType = "query"),
			@ApiImplicitParam(name = "page.pageSize", value = "单页记录数", required = true, dataType = "integer", paramType = "query") })
	public PageResult<List<BackPropViewVo>> showCatePropView(@RequestBody @ApiParam PropViewSearchVo searchVo, @Inject @ApiIgnore Pagination page) {
		return propertiesInfoService.showCatePropView(searchVo, page);
	}
	
	/**
	 * 设置平台分类下面属性的可见性与显示的位置
	 * @author zhuangjiajian
	 * @date 2017-8-17 15:39:25
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/setCatePropInfoViewAndPosition", method = RequestMethod.POST)
	@ApiOperation(value = "5期-zhuangjiajian-设置分类下面属性的可见性与显示的位置", notes = "设置分类下面属性的可见性与显示的位置")
	@Valids({ @Valid(name = "vo.sysId", required = true, minValue = 1) })
	public Result<Boolean> setCatePropInfoViewAndPosition(@RequestBody @ApiParam BackSetCatePropViewVo vo) {
		
		return propertiesInfoService.setCatePropInfoViewAndPosition(vo.getUpdateId(), vo.getCatId(), vo.getSysId(), vo.getPropViewVo());
		
	}
	
	/**
	 * 平台分类属性值的展示
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/showCatePropValView", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-平台分类属性值的展示", notes = "平台分类属性值的展示")
	@Valids({ @Valid(name = "sysId", required = true, minValue = 1), @Valid(name = "device", regex = "PC|WAP"), @Valid(name = "page.pageNumber", required = true), //
			@Valid(name = "page.pageSize", required = true) })
	@ApiImplicitParams({ @ApiImplicitParam(name = "catId", value = "分类ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "sysId", value = "系统ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "propId", value = "属性ID", required = true, dataType = "long", paramType = "query"),
			@ApiImplicitParam(name = "device", value = "设备", required = true, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "page.pageNumber", value = "页码", required = true, dataType = "integer", paramType = "query"),
			@ApiImplicitParam(name = "page.pageSize", value = "单页记录数", required = true, dataType = "integer", paramType = "query") })
	public PageResult<List<BackPropValViewVo>> showCatePropValView(@RequestParam(value = "device") String device, @RequestParam(value = "catId") Long catId,
			@RequestParam(value = "propId") Long propId, @RequestParam(value = "sysId") Long sysId, @Inject @ApiIgnore Pagination page) {
		return propertiesInfoService.showCatePropValView(device, sysId, catId, propId, page);
	}
	
	/**
	 * 设置分类下面属性的属性值可见性
	 * @author zhuangjiajian
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/setCatePropValView", method = RequestMethod.POST)
	@ApiOperation(value = "5期-zhuangjiajian-设置分类下面属性的属性值可见性", notes = "设置分类下面属性的属性值可见性-backPropValViewVo只需要传propValId和isDisplay ")
	@Valids({ @Valid(name = "vo.device", regex = "PC|WAP"), @Valid(name = "vo.sysId", required = true, minValue = 1) })
	public Result setCatePropValView(@RequestBody @ApiParam BackSetCatePropValViewVo vo) {
		
		return propertiesInfoService.setCatePropValView(vo.getDevice(), vo.getUpdate(), vo.getSysId(), vo.getCatId(), vo.getPropId(), vo.getBackPropValViewVo());
	}
	
	/**
	 * 查询分类属性通用  下的属性 属性值信息
	 * @author zhuangjiajian
	 * @date 2017-8-15 16:14:44
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findPropAndVal", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-添加商品时 下方的通用分类属性信息列表", notes = "通用分类属性信息列表")
	@ApiImplicitParams({ @ApiImplicitParam(name = "catId", value = "分类ID", required = true, dataType = "long", paramType = "query") })
	@Valids({})
	public Result<List<PropDetailVo>> findPropAndVal(@RequestParam(value = "catId", required = true) Long catId) {
		Result<List<PropDetailVo>> result = new Result<List<PropDetailVo>>();
		List<PropDetailVo> list = propertiesInfoService.findPropAndVal(catId);
		
		result.setErrorCode(ErrorCode.SUCCESS);
		result.setData(list);
		return result;
	}
	
	/**
	 * 通过属性值ID或者属性值名称查询属性值信息
	 * @author zhuangjiajian
	 * @date 2017-8-15 16:14:44
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findPropValByIdAndName", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-通过属性值ID或者属性值名称查询属性值信息", notes = "通过属性值ID或者属性值名称查询属性值信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "search", value = "属性值ID或者属性值名称", required = false, dataType = "string", paramType = "query"),
			@ApiImplicitParam(name = "propId", value = "属性ID", required = true, dataType = "string", paramType = "query") })
	@Valids({})
	public Result<List<PropertiesVal>> findPropValByIdAndName(@RequestParam(value = "search", required = false) String search,
			@RequestParam(value = "propId", required = true) Long propId) {
		Result<List<PropertiesVal>> result = new Result<List<PropertiesVal>>();
		
		List<PropertiesVal> data = propertiesInfoService.findPropValByIdAndName(search, propId);
		if (data == null || data.isEmpty()) {
			result.setErrorCode(ErrorCode.NOT_FIND);
			return result;
		}
		result.setData(data);
		result.setErrorCode(ErrorCode.SUCCESS);
		return result;
	}
	
	/**
	 * 通过基础属性ID查询出已设置的属性值信息
	 * @author zhuangjiajian
	 * @date 2017-8-19 16:09:03
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/findPropValByPropId", method = RequestMethod.GET)
	@ApiOperation(value = "5期-zhuangjiajian-通过基础属性ID查询出属性值信息", notes = "通过基础属性ID查询出属性值信息")
	@ApiImplicitParams({ @ApiImplicitParam(name = "propId", value = "属性ID", required = true, dataType = "string", paramType = "query") })
	@Valids({})
	public Result<List<PropertiesVal>> findPropValByPropId(@RequestParam(value = "propId", required = true) Long propId) {
		Result<List<PropertiesVal>> result = new Result<List<PropertiesVal>>();
		
		List<PropertiesVal> data = propertiesInfoService.findPropValByPropId(propId);
		if (data == null || data.isEmpty()) {
			result.setErrorCode(ErrorCode.SUCCESS);
			result.setData(data);
			result.setMessage("没有找到属性值信息");
			return result;
		}
		result.setData(data);
		result.setErrorCode(ErrorCode.SUCCESS);
		return result;
	}
	
}
